﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_UPDMS_FIT_TRAINING_TYPE_Select_Paging')
	BEGIN
		DROP Procedure usp_UPDMS_FIT_TRAINING_TYPE_Select_Paging
	END
GO

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
/******************************************************************************
**	Name : usp_UPDMS_FIT_TRAINING_TYPE_Select_Paging
**	Desc : 운동종류관리를 조회한다.
**	Test Exec Query : Exec usp_UPDMS_FIT_TRAINING_TYPE_Select_Paging 0, 20, '벤치', '', '', 'ko'
**	Called by : Fit_Dac_UPDMS_FIT_TRAINING_TYPE.cs
**	Program ID : Fit1010m
**	Auth : 송시명
**	Date : 2014-05-19
*******************************************************************************
**	Change History
*******************************************************************************
**	Date:		Author:		Description:
**	--------	--------	---------------------------------------
**	
*******************************************************************************/
CREATE PROC [dbo].[usp_UPDMS_FIT_TRAINING_TYPE_Select_Paging]
@li_st_page int,
@li_ed_page int,
@ls_training_part nvarchar(5),
@ls_training_nm nvarchar(200),
@ls_favorite_yn nvarchar(1),
@ls_lang_set nvarchar(2)
AS
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON

SELECT a.Seq,
       a.Training_Type_Id,
       a.Training_Part,
	   a.Training_Part_Nm,
	   a.Training_Nm,
       a.Training_Muscle_Major,
       a.Training_Muscle_Minor,
       a.Howto,
       a.Precaution,
	   a.Tip,
	   a.Weight_Calc_Rate,
	   a.View_Order,
       a.Favorite_Yn,
       a.Use_Yn,
       a.Summary
  FROM (
       SELECT ROW_NUMBER() OVER(ORDER BY Training_Part, View_Order ASC) AS Rnum,
              Seq,
              Training_Type_Id,
              Training_Part,
              dbo.ufn_UPDMS_Get_Code_Name(Training_Part, 'FIT', @ls_lang_set) AS Training_Part_Nm,
              Training_Nm,
              Training_Muscle_Major,
              Training_Muscle_Minor,
              Howto,
              Precaution,
              Tip,
              Weight_Calc_Rate,
              View_Order,
              Favorite_Yn,
              Use_Yn,
              '<div title="요약" class="sbtn sbtn_summary" onclick="goTrainingTypeSummaryPage(''' + Training_Type_Id + ''');"></div>' AS Summary
          FROM UPDMS_FIT_TRAINING_TYPE WITH(NOLOCK)
         WHERE Training_Part LIKE @ls_training_part + '%'
           AND Training_Nm LIKE '%' + @ls_training_nm + '%'
           AND Favorite_Yn LIKE @ls_favorite_yn + '%'
       ) a
 WHERE a.Rnum > @li_st_page AND a.Rnum <= @li_ed_page

GO